﻿namespace NMortgage.UI.Tests
{
    using System;

    using Caliburn.Micro;

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    using Moq;

    using NMortgage.UI.Events;
    using NMortgage.UI.Model;
    using NMortgage.UI.ViewModels;
    using Microsoft.Practices.Unity;

    [TestClass]
    public class FeeViewModelTest : TestBase<FeeViewModel>
    {
        Fee _fee;
        #region Methods

        [TestMethod]
        public void Cancel_will_publish_CancelEvent()
        {
            Subject.Cancel();
            Helper.EventAggregator.Verify(x => x.Publish(It.Is<CancelEvent>(c => c.Source.GetType() == typeof(FeeViewModel))));
        }

        [TestMethod]
        public void FeeViewModel_Not_Null()
        {
            var subject = new FeeViewModel(null);
            Assert.IsNotNull(subject);
        }

        [TestInitialize]
        public void Initialize()
        {
            Subject.Fee = FeeCollectionTest.GetParameter0();
            _fee = Subject.Fee;

            Subject = Helper.Resolve<FeeViewModel>(new ParameterOverride("parameter", _fee));

        }

        [TestMethod]
        public void Must_have_valid_Fee()
        {
            bool actual;
            bool expected = true;
            Fee validationTarget = FeeCollectionTest.GetParameter0();
            validationTarget.Months = 1;

            Subject.Fee = validationTarget;

            actual = Subject.IsValid;
            Assert.AreEqual(expected, actual);
        }

        #endregion Methods
    }
}